<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>紫色鹭</title>
    <link rel="stylesheet" href="../css/common.css">
    <link rel="stylesheet" href="../css/style.css">
</head>
<body>
<div id="header_01_html">
    <iframe id="header_01" src="head_01.html" frameborder="0"></iframe>
</div>
<div id="head_search_html">
    <iframe id="head_search" src="head_search.html" frameborder="0"></iframe>
</div>
<div class="container store_info clearfix">
    <div class="store_tab">
        <a class="active">基本信息</a>
        <a mhref="store_banner.html" class="store_banner has_store banner-admmin" v-show="storeId!=false?true:false">轮播管理</a>
        <a mhref="store_product.html" class="has_store product-admin">商品管理</a>
        <a mhref="store_manage.html" class="has_store order-admin">订单管理</a>
        <a class="has_store store-enter">企业认证</a>
        <!--<a mhref="store_evaluate.html" class="has_store evaluate-admin">评价管理</a>-->
    </div>
    <div class="right">
        <div class="title">基本信息填写</div>
        <table>
            <tr>
                <td><i class="c_red">* </i>个人姓名：</td>
                <td><input type="text" class="name-per" v-model="name"></td>
            </tr>
            <tr>
                <td><i class="c_red">* </i>所属地区：</td>
                <td>
                    <select name="" id="province">
                        <option value="">省</option>
                    </select>
                    <select name="" id="city">
                        <option value="">市</option>
                    </select>
                    <select name="" id="area">
                        <option value="">区</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td><i class="c_red">* </i>联系电话：</td>
                <td><input type="text" class="phone-per" v-model="phone"></td>
            </tr>
            <tr>
                <td><i class="c_red">* </i>QQ：</td>
                <td><input type="text" id="QQ" v-model="qq"></td>
            </tr>
            <tr>
                <td colspan="2">
                    <div class="submit">确认提交</div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="tabRight">
    <div class="first">
        <ul>
            <li><a target="_blank" class="icon_admin_white" title=""></a></li>
            <li>
                <a target="_blank" class="go-shopcard c-fff">
                    <i class="icon_shopcar_white"></i>
                    <p class="mt10">购<br>物<br>车</p>
                    <span class="car-num pos-Sty1">0</span>
                </a>
            </li>
            <li>
                <a target="_blank" class="icon_list_white mt10 go-myorder" title="订单"></a>
                <a target="_blank" class="icon_collect_white mt10 go-myhas" title="收藏"></a>
                <a target="_blank" class="icon_history_white mt10 go-record" title="记录"></a>
            </li>
        </ul>
    </div>
    <div class="second">
        <a target="_blank" class="icon_edit_white"></a>
        <a target="_blank" class="icon_top_white mt10"></a>
    </div>
</div>
</body>
<script src="../js/config.js"></script>
<script>
    var provinceId = null,cityId = null,districtId = null;
    initAreaSelect();
    var id = localStorage.getItem("storeId");

    var app = new Vue({
        el: '.store_info',
        data: {
            name:'',
            phone:'',
            qq:'',
            type:localStorage.getItem('type'),
            storeId:localStorage.getItem('storeId')
        },
        beforeCreate: function () {
            var that = this;
            get_ajax("/sys/store/view", {id:id},function (data) {
                that.name = data.name;
                that.phone = data.phone;
                that.qq = data.qq;
                provinceId = data.provinceId;
                cityId = data.cityId;
                districtId = data.districtId;

                //三级回显
                $("#province").val(provinceId).trigger("change");
                $("#city").val(cityId).trigger("change");
                $("#area").val(districtId);
            })


        },
    })


    //编辑店铺信息
    $('.submit').on('click',function(){
        if(!$('.name-per').val()){
            layer.msg('姓名不能为空！')
            return
        }
        if(!$('#province').val()){
            layer.msg('所属地区不能为空！')
            return
        }
        if(!$('#city').val()){
            layer.msg('所属地区不能为空！')
            return
        }
        if(!$('#area').val()){
            layer.msg('所属地区不能为空！')
            return
        }
        if(!$('#QQ').val()){
            layer.msg('QQ号码不能为空！')
            return
        }
        if(!$('.phone-per').val()){
            layer.msg('手机号码不能为空！')
            return
        }
        if(!phone_rexg.test($('.phone-per').val())){
            layer.msg('手机号码不正确！')
        }

        get_ajax("/sys/store/addInfo", {
            id:id,
            name:$('.name-per').val(),
            provinceId:$('#province').val(),
            cityId:$('#city').val(),
            districtId:$('#area').val(),
            address:'',
            phone:$('.phone-per').val(),
            qq:$('#QQ').val()
        }, function (data) {
            layer.msg('提交成功！');
            console.log(data);
            get_ajax("/web/auth/info",{},function (data) {
                if(data.storeId){
                    localStorage.setItem("storeId",data.storeId);
                }
            })
        })
    })

</script>
</html>